package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectJudgePO;
import com.cw.subject.infra.basic.mapper.SubjectJudgePODao;
import com.cw.subject.infra.basic.service.SubjectJudgePOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 判断题(SubjectJudgePO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-11 15:31:55
 */
@Service("subjectJudgeService")
public class SubjectJudgePOServiceImpl implements SubjectJudgePOService {
    @Resource
    private SubjectJudgePODao subjectJudgePODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectJudgePO queryById(Integer id) {
        return this.subjectJudgePODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectJudgePO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectJudgePO insert(SubjectJudgePO subjectJudgePO) {
        this.subjectJudgePODao.insert(subjectJudgePO);
        return subjectJudgePO;
    }

    /**
     * 修改数据
     *
     * @param subjectJudgePO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectJudgePO update(SubjectJudgePO subjectJudgePO) {
        this.subjectJudgePODao.update(subjectJudgePO);
        return this.queryById(subjectJudgePO.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectJudgePODao.deleteById(id) > 0;
    }

    @Override
    public List<SubjectJudgePO> queryByCondition(SubjectJudgePO subjectJudgePO) {
        return this.subjectJudgePODao.queryAllByLimit(subjectJudgePO);
    }
}
